#include <cstdio>
#include <cstring>
#include <queue>

const int N = 255, inf = 0x3fffffff;
int n, s, t, rcnt, ccnt;
int e_cnt = 1, heads[N], dis[N], cur[N];

struct Edge {
  int v, nxt, f;
} e[N * (N + 2)];

struct Segment {
  int x1, x2, y1, y2;
  Segment() {}
  Segment(int _x1, int _x2, int _y1, int _y2)
      : x1(_x1), x2(_x2), y1(_y1), y2(_y2) {}
} row[N], col[N];

inline void add(int u, int v, int f) {
  e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt, e[e_cnt].f = f;
  e[++e_cnt].v = u, e[e_cnt].nxt = heads[v], heads[v] = e_cnt, e[e_cnt].f = 0;
}

inline bool check(const Segment &a, const Segment &b) {
  return a.x1 <= b.x1 && a.x2 >= b.x1 && b.y1 <= a.y1 && b.y2 >= a.y1;
}

inline bool bfs() {
  std::queue<int> q;
  memset(dis, 0, sizeof(dis));
  memcpy(cur, heads, sizeof(heads));
  q.push(s);
  dis[s] = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = heads[u], v; i; i = e[i].nxt) {
      if (!dis[v = e[i].v] && e[i].f) {
        q.push(v);
        dis[v] = dis[u] + 1;
        if (v == t) {
          return true;
        }
      }
    }
  }
  return false;
}

int dinic(int x, int flow) {
  if (x == t) return flow;
  int rest = flow, k;
  for (int i = cur[x], v; i && rest; i = e[i].nxt) {
    if (dis[v = e[i].v] == dis[x] + 1 && e[i].f) {
      cur[x] = i;
      k = dinic(v, std::min(rest, e[i].f));
      if (!k) dis[v] = 0;
      e[i].f -= k, e[i ^ 1].f += k, rest -= k;
    }
  }
  return flow - rest;
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("P3033 Cow Steeplechase G.in", "r", stdin);
  freopen("P3033 Cow Steeplechase G.out", "w", stdout);
#endif
#endif

  scanf("%d", &n);
  for (int i = 1, x1, y1, x2, y2; i <= n; ++i) {
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    if (x1 > x2) std::swap(x1, x2);
    if (y1 > y2) std::swap(y1, y2);
    if (x1 == x2)
      col[++ccnt] = Segment(x1, x2, y1, y2);
    else
      row[++rcnt] = Segment(x1, x2, y1, y2);
  }
  s = 0, t = n + 1;
  for (int i = 1; i <= rcnt; ++i) add(s, i, 1);
  for (int i = rcnt + 1; i <= n; ++i) add(i, t, 1);
  for (int i = 1; i <= rcnt; ++i)
    for (int j = 1; j <= ccnt; ++j) {
      if (check(row[i], col[j])) add(i, rcnt + j, 1);
    }
  int ans = 0, flow;
  while (bfs()) {
    if ((flow = dinic(s, inf))) ans += flow;
  }
  printf("%d", n - ans);
  return 0;
}